package edu.ynu.se.xiecheng.achitectureclass.project.dao;

import edu.ynu.se.xiecheng.achitectureclass.project.entity.CameraData;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface CameraDataRepository extends JpaRepository<CameraData, Long> {
    @Query("SELECT c FROM CameraData c WHERE c.deviceSerial = :deviceSerial ORDER BY c.createTime DESC")
    Optional<CameraData> findLatestByDeviceSerial(@Param("deviceSerial") String deviceSerial);

    Optional<CameraData> findByDeviceSerial(String deviceSerial);
}